<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>空状态 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/empty/empty.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 空状态</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>📭 空状态演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>空状态</h3>
                        <div id="emptyState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>错误状态</h3>
                        <div id="errorState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>网络错误</h3>
                        <div id="networkState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>搜索无结果</h3>
                        <div id="searchState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>带操作按钮</h3>
                        <div id="actionState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>小尺寸</h3>
                        <div id="smallState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>大尺寸</h3>
                        <div id="largeState"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>自定义内容</h3>
                        <div id="customState"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/empty/empty.css"&gt;
&lt;script src="components/empty/empty.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="emptyContainer"&lt;/div&gt;

// 3. 初始化空状态组件
const empty = new Empty({
    container: '#emptyContainer',
    type: 'empty',
    title: '暂无数据',
    description: '暂时没有相关数据',
    actions: [
        {
            key: 'retry',
            label: '重试',
            onClick: () => {
                console.log('重试');
            }
        }
    ]
});

// 4. 设置类型
empty.setType('error');

// 5. 设置标题
empty.setTitle('加载失败');</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/empty/empty.js"></script>
    <script>
        // 空状态
        new Empty({
            container: '#emptyState',
            type: 'empty'
        });

        // 错误状态
        new Empty({
            container: '#errorState',
            type: 'error'
        });

        // 网络错误
        new Empty({
            container: '#networkState',
            type: 'network'
        });

        // 搜索无结果
        new Empty({
            container: '#searchState',
            type: 'search'
        });

        // 带操作按钮
        new Empty({
            container: '#actionState',
            type: 'error',
            title: '加载失败',
            description: '服务器出错了，请稍后重试',
            actions: [
                {
                    key: 'retry',
                    label: '重试',
                    onClick: () => {
                        alert('重试加载');
                    }
                },
                {
                    key: 'home',
                    label: '返回首页',
                    onClick: () => {
                        alert('返回首页');
                    }
                }
            ]
        });

        // 小尺寸
        new Empty({
            container: '#smallState',
            type: 'empty',
            size: 'small'
        });

        // 大尺寸
        new Empty({
            container: '#largeState',
            type: 'empty',
            size: 'large'
        });

        // 自定义内容
        new Empty({
            container: '#customState',
            type: 'search',
            title: '未找到匹配的商品',
            description: '请尝试其他搜索条件或浏览其他分类',
            actions: [
                {
                    key: 'search',
                    label: '重新搜索',
                    onClick: () => {
                        alert('重新搜索');
                    }
                }
            ]
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 14px;
            color: var(--text-primary);
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: 1fr;
            }
        }
    </style>
</body>
</html>
